package com.gusti.mensajes.util;

import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

/**
 * 
 * @author gusti
 *
 */
public class Debug {

	public static boolean debugActivated = true;

    /**
     * 
     * @param log
     * 		message to log into console
     */
	public static void log( String log ){
    	if( debugActivated && log != null ){
        	System.out.println( "[INFO - " + getDateTime() + "]: " + log );
        }
	}

    /**
     * 
     * @param e
     * 		exception to log into console
     */
	public static void error( Exception e ){
    	if( debugActivated && e != null ){
        	System.out.println( "[ERROR - " + getDateTime() + "]: " + e.getClass().toString() + " | " + e.getMessage() );
        }
	}
	
	private static String getDateTime() {
		GregorianCalendar gregorianCalendar = new GregorianCalendar();
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

		return simpleDateFormat.format( gregorianCalendar.getTime() );
	}
}
